b23e1beefb472a84016c87d987e2fe2260360aa4,adal/src/telemetry/java/com/microsoft/aad/adal/DefaultEvent.java,DefaultEvent,setDefaults,#Context#String#,98

Before Change


        if (mDefaultEventCount == 0) {
            mEventList.add(new Pair<>(EventStrings.APPLICATION_NAME, sApplicationName));
            mEventList.add(new Pair<>(EventStrings.APPLICATION_VERSION, sApplicationVersion));
            mEventList.add(new Pair<>(EventStrings.CLIENT_ID, sClientId));
            mEventList.add(new Pair<>(EventStrings.CLIENT_IP, sClientIp));
            mEventList.add(new Pair<>(EventStrings.DEVICE_ID, sDeviceId));
            mDefaultEventCount = mEventList.size();

After Change



    void setDefaults(final Context context, final String clientId) {

        sClientId = clientId;
        sApplicationName = context.getPackageName();
        try {
            sApplicationVersion = context.getPackageManager().getPackageInfo(sApplicationName, 0).versionName;
        } catch (PackageManager.NameNotFoundException nnfe) {
            sApplicationVersion = "NA";
        }

        //TODO: Getting IP will require network permissions do we want to do it?
        sClientIp = "NA";

        try {
            sDeviceId = StringExtensions.createHash(Secure.getString(context.getContentResolver(), Secure.ANDROID_ID));
        } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
            sDeviceId = "";
        }

        if (mDefaultEventCount == 0) {
            setEvent(EventStrings.APPLICATION_NAME, sApplicationName);
            setEvent(EventStrings.APPLICATION_VERSION, sApplicationVersion);
            setEvent(EventStrings.CLIENT_ID, sClientId);
            setEvent(EventStrings.CLIENT_IP, sClientIp);
            setEvent(EventStrings.DEVICE_ID, sDeviceId);
            mDefaultEventCount = mEventList.size();